from appengine_django.models import BaseModel
from google.appengine.ext import db
from datetime import datetime

# This class defines the "Item" model, which is the definition for each type of item that has been identified by the tracker.  It contains information about the tweaks of all item instances of that given item, such as averages and frequencies.

class item_def(db.Model):
    itemname = db.StringProperty("Object")
    # These are the averages for the corresponding item instances.  These are updated by on the fly durin the submission process.
    num_insts = db.IntegerProperty()
    avglevel = db.IntegerProperty()
    minlevel = db.IntegerProperty()
    maxlevel = db.IntegerProperty()
    avgac = db.IntegerProperty()
    minac = db.IntegerProperty()
    maxac = db.IntegerProperty()
    avgdr = db.IntegerProperty()
    mindr = db.IntegerProperty()
    maxdr = db.IntegerProperty()
    avghr = db.IntegerProperty()
    minhr = db.IntegerProperty()
    maxhr = db.IntegerProperty()
    avghp = db.IntegerProperty()
    minhp = db.IntegerProperty()
    maxhp = db.IntegerProperty()
    avgmana = db.IntegerProperty()
    minmana = db.IntegerProperty()
    maxmana = db.IntegerProperty()
    avgsbr = db.IntegerProperty()
    minsbr = db.IntegerProperty()
    maxsbr = db.IntegerProperty()
    avgss = db.IntegerProperty()
    minss = db.IntegerProperty()
    maxss = db.IntegerProperty()
    avgsrod = db.IntegerProperty()
    minsrod = db.IntegerProperty()
    maxsrod = db.IntegerProperty()
    avgspar = db.IntegerProperty()
    minspar = db.IntegerProperty()
    maxspar = db.IntegerProperty()


# This class defines the "Item Instance" model which contains information which varies between tweaks for a particular item type.  For example an item with name "a diamond orb of Tyche" will have the same name and type for all instances, but could have very different values for the HP and Mana fields.  Each item instance is required to reference a particular item definition.

class item_instance(db.Model):
    parentitem = db.ReferenceProperty(item_def)
    itemname = db.StringProperty("Item Name")
    itemtype = db.StringProperty("Item Type")
    effects = db.StringListProperty("Effects")
    equiplocs = db.StringListProperty("Equipable Location(s):")
    weight = db.IntegerProperty("Weight")
    value = db.IntegerProperty("Value")
    dateadded = db.DateTimeProperty('Date Added')
    level = db.IntegerProperty("Level Restriction")
    ac = db.IntegerProperty("AC")
    noclasses = db.StringListProperty("Class Restrictions")
    damroll = db.IntegerProperty()
    hitroll = db.IntegerProperty()
    hp = db.IntegerProperty()
    mana = db.IntegerProperty()
    sbr = db.IntegerProperty("Saving Breath")
    ss = db.IntegerProperty("Saving Spell")
    srod = db.IntegerProperty("Saving Rod")
    spar = db.IntegerProperty("Saving Paralysis")
    
